import { defineStore } from "pinia"
import { Tag } from "@/models/tag"
import { tagApi } from "@/services"

const useTagStore  = defineStore('Tag', {
    // state
    state:() =>({
        selectedIds:[] as number[],   // 选定的标签id列表
        tagListResult: [] as Tag[]
    }),

    // actions
    actions:{
        // 获得课程标签列表
        async getCourseTags() {
            try {
                this.tagListResult = await tagApi.getCourseTags()
                console.log("Course Tags Result:", this.tagListResult)         
            } catch(err) {
        
            }
        },

        // 获得资料标签列表
        async getMaterialTags() {
            try {
                this.tagListResult = await tagApi.getMaterialTags()
                console.log("Material Tags Result:", this.tagListResult)         
            } catch(err) {
        
            }
        },

        // 获得行家标签列表
        async getExpertTags() {
            try {
                this.tagListResult = await tagApi.getExportTags()
                console.log("Expert Tags Result:", this.tagListResult)         
            } catch(err) {
        
            }
        },

    },
    getters:{
        TagSource:(state) => state.tagListResult,
    }
})

export default useTagStore;